/**
 * @author lzm
 * @date 2025/2/14 20:52
 * @description
 */
public class LogCalculatorV2 {

    public Calculator calculator;

    public LogCalculatorV2(Calculator calculator) {
        this.calculator = calculator;
    }

    public int sum(int a, int b) {
        System.out.printf("程序的入参是a=%s,b=%s%n", a, b);
        long startTime = System.currentTimeMillis();
        // 调用父类的sum方法, 实现代码复用的同时，还实现了新需求，增加了打印日志的功能
        int result = calculator.sum(a, b);
        long endTime = System.currentTimeMillis();
        System.out.println("程序的计算结果是result=" + result + ", 耗时：" + (endTime - startTime) + "毫秒");
        return result;
    }

}
